var images = ['轮播一.jpg','轮播二.jpg','轮播三.jpg']
var index = 0
var timer=null
function move(obj,target,step){
    clearInterval(timer)//1.先清除定时器
    //2.启动定时器
    timer=setInterval(function(){
        var left=obj.offsetLeft//获取div得当前左边距
        //3.通过if_else结构确定何时执行动画，何时结束动画
        if(left==target){
            clearInterval(timer)
        }else{
            obj.style.left=(left+step)+'px'
        }
    },50)
}
window.onload = function(){
    var left = document.getElementsByClassName('left')[0]
    left.onmouseover=function(){
        move(this,0,10)
    }
    left.onmouseout=function(){
        move(this,-190,-10)
    }

    var timer = null
    timer = setInterval(function(){
        var img = document.getElementById('dd_scroll')
        img.src = '../images/' + images[index]
        index++
        if(index == 3)
        index = 0
    },2000)

            var btn = document.getElementById('div1')
            btn.onclick = function(){
                var img = document.getElementById('dd_scroll')
                img.src = '../images/轮播一.JPG'
            }
            var btn = document.getElementById('div2')
            btn.onclick = function(){
                var img = document.getElementById('dd_scroll')
                img.src = '../images/轮播二.JPG'
            }
            var btn = document.getElementById('div3')
            btn.onclick = function(){
                var img = document.getElementById('dd_scroll')
                img.src = '../images/轮播三.JPG'
            }
}
$(function () {
    $('#txtSearch').keyup(function () {
        console.log('key:', $(this).val())
        //JS跨域请求禁止，必须通过特殊技术手段才能访问
        $.ajax({
            url: 'http://www.baidu.com/su',
            type: 'get',
            data: { wd: $(this).val() },
            dataType: 'jsonp',          // 使用jsonp跨域请求
            jsonp: 'cb',                //设置跨域返回的回调函数名称
            success: function (result) {
                //数据请求到以后，必须在success中处理后续操作
                $('#lstSearch').empty()
                datas = result.s
                // for (var i = 0; i < result.s.length; i++) {
                //     $('#lstSearch').append(`<li>${result.s[i]}</li>`)
                // }
                $.each(result.s,function(idx,item){
                    $('#lstSearch').append(`<li>${item}</li>`)
                })
            }
        })
    })
})

       
           


